package com.study.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/test")
public class TestController {

    @ResponseBody
    @RequestMapping("/hello")
    public Object testTemplates(HttpServletRequest request) {
//        ModelAndView view = new ModelAndView();
//        view.addObject("name", "你好");
//        view.setViewName("hello");
        request.setAttribute("name", "nihao 你好");
        return "hellohhhhcsacsa";
    }

    @RequestMapping("/hello2")
    public String testTemplates2(HttpServletRequest request) {
//        ModelAndView view = new ModelAndView();
//        view.addObject("name", "你好");
//        view.setViewName("hello");
        request.setAttribute("name", "name");
        request.setAttribute("password", "password");
        return "hello";
    }

}
